package com.trailwalker.traceability.service;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
import com.alibaba.excel.read.listener.ReadListener;
import com.trailwalker.JavaUtils.log.LogUtils;

import java.io.File;

/**
 * @author Trailwalker
 * @create 2021-11-14 22:44
 */
public class ExcelService {

    public static void read(File file, Class clz, ReadListener readListener) {
        if (file != null) {
            try {
                ExcelReaderBuilder readerBuilder = EasyExcel.read(file.getAbsoluteFile(), clz, readListener);
                ExcelReaderSheetBuilder sheetBuilder = readerBuilder.sheet();
                sheetBuilder.doRead();
            } catch (Exception e) {
                e.printStackTrace();
                LogUtils.logE(e);
            }
        }
    }
}
